Previous | Index | Next |

Random access iterators

A random access iterator must implement the methods defined in the interface RandomIterator api. These methods, in addition to the requirements of bidirectional iterators, are summarized in the table below. Assume that r and s are random access iterators, n is an integer and v is a value of type Object.

Random access iterator requirements
expression return type assertion/note
pre/post-condition
r.next(n) Iterator Move the iterator forward n times. If n is negative the iterator is moved backwards n times.
r.prev(n) Iterator Move the iterator backward n times. If n is negative the iterator is moved forwards n times.
r.get(n) Object Deference the iterator n position forward (backward is n is negative).
r.put(v, n) Object Deference the iterator n position forward (backward is n is negative).
r.less(s) boolean a total ordering relation.


Previous | Index | Next |